package interview.huawei.tjt.od;

/**
 * @Author CandyWall
 * @Date 2022/2/22--15:29
 * @Description
 */
public class P1 {
    public int maxLength(String s, String t, int maxCost) {
        int length = 0;
        int cost = 0;
        for (int i = 0; i < s.length(); i++) {
            char a = s.charAt(i);
            char b = t.charAt(i);
            cost += Math.abs(a - b);
            if (cost <= maxCost) {
                length++;
            } else {
                break;
            }
        }
        return length;
    }

    public static void main(String[] args) {
        System.out.println(new P1().maxLength("abcd", "cdef", 3));
    }
}
